# app/config.py

import os
from dotenv import load_dotenv
from pathlib import Path

# 加载 .env 文件中的环境变量
load_dotenv()

class Config:
    # FastAPI 配置
    SECRET_KEY = os.getenv('SECRET_KEY', 'your_default_secret_key')
    DEBUG = os.getenv('DEBUG', 'False') == 'True'

    # 数据库配置
    DATABASE_URL = os.getenv('DATABASE_URL', 'postgresql+psycopg2://db_user:db_password@localhost/dco_a02_db')

    # SMTP 配置
    SMTP_SERVER = os.getenv('SMTP_SERVER', 'smtp.gmail.com')
    SMTP_PORT = int(os.getenv('SMTP_PORT', 587))
    SMTP_USERNAME = os.getenv('SMTP_USERNAME', 'your_email@gmail.com')
    SMTP_PASSWORD = os.getenv('SMTP_PASSWORD', 'your_smtp_password')
    EMAIL_RECIPIENT = os.getenv('EMAIL_RECIPIENT', 'recipient@example.com')
    EMAIL_SUBJECT = os.getenv('EMAIL_SUBJECT', 'DCO 验证失败通知')
    EMAIL_BODY_TEMPLATE = os.getenv('EMAIL_BODY_TEMPLATE', '以下提交缺少有效的 `Signed-off-by` 行，请在每次提交时使用 `git commit -s` 添加签名：\n\n')

    # Webhook 配置
    WEBHOOK_SECRET = os.getenv('WEBHOOK_SECRET', 'your_webhook_secret')

    # 日志配置
    LOG_FILE = os.getenv('LOG_FILE', 'logs/app.log')

# 实例化配置
config = Config()
